package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2024/9/9 13:26
 * @apiNote
 */

public class Test01456MaxVowels {
    public int maxVowels(String s, int k) {
        char[] chars = s.toCharArray();
        int ans = 0;
        int vowel = 0;
        for(int i =0 ;i<s.length();i++){
            if(chars[i] == 'a' || chars[i] == 'e' || chars[i] == 'i' || chars[i] == 'o' || chars[i] == 'u'){
                vowel++;
            }
            if(i < k-1){
                continue;
            }
            ans = Math.max(ans,vowel);
            char out = chars[i-k+1];
            if(out == 'a' || out == 'e' || out == 'i' || out == 'o' || out == 'u'){
                vowel--;
            }

        }
        return ans;
    }
}
